package org.kessy.store.api;

import java.util.Collection;

import org.kessy.common.model.meta.MBase;
import org.kessy.common.param.MetaQueryParam;

/***
 * 
 * @author leo.liu
 * Interface to provide APIs to CRUD meta data
 */
public interface MetaStoreIFC {
    /***
     * query meta objects by metaQueryParam
     * @param metaQueryParam    the input parameter to indicate what to query, what's the 
     * condition, page or not...
     * @return                  the meta objects in Collection match the input parameter 
     */
    public Collection<MBase> queryMBases(MetaQueryParam metaQueryParam);
    
    /***
     * query single meta object by metaQueryParam
     * if there are more than one meta objects match the input parameter, only 
     * the first one will be return
     * @param metaQueryParam    the input parameter to indicate what to query, what's the
     * condition, page or not...
     * @return                  the meta object matches the input parameter
     */
    public MBase queryMBase(MetaQueryParam metaQueryParam);
    
    /***
     * query the meta objects count by metaQueryParam
     * @param metaQueryParam    the input parameter to indicate the query condition
     * @return
     */
    public int queryMBaseCount(MetaQueryParam metaQueryParam);
    
    /***
     * persist meta objects, any object will be insert, update, or delete according 
     * to its persistType. any referenced meta objects or nested referenced meta
     * objects are also to be persist. and the relation between the meta objects 
     * will be persist at the same time
     * @param mBases    the meta objects to be persist
     */
    public void persistMBases(Collection <MBase> mBases);
    
    /***
     * persist meta object, this meta object and all referenced, nested referenced 
     * meta objects are all will be persist, according to their persistType.
     * the relation between the meta objects will be persist at the same time
     * @param mBase     the meta object to be persist
     */
    public void persistMBase(MBase mBase);
}
